<?php

namespace addons\exam\model;
use app\common\model\User;
use fast\Random;

class UserCommissionModel extends BaseModel
{
    // 表名
    protected $name = 'user_commission';

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;

// 追加属性
    protected $append = [
        'createtime_text'
    ];

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function getCreateTimeTextAttr($value, $data){
        if(isset($data['createtime'])){
            $value = date("Y-m-d H:i:s",$data['createtime']);
        }
        return $value;
    }

}
